package com.xmb.wechat.view.wechat.chat;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;
import com.xmb.wechat.R;
import com.xmb.wechat.R2;
import com.xmb.wechat.base.BaseActivity;
import com.xmb.wechat.bean.WechatContactBean;
import com.xmb.wechat.common.Constant;

import butterknife.BindView;

/**
 * @Author lijiangop
 * @CreateTime 2020/4/28 09:25
 */
public class WechatVoiceCallDetailActivity extends BaseActivity {

    @BindView(R2.id.iv_avatar)
    ImageView mIvAvatar;
    @BindView(R2.id.iv_mute)
    ImageView mIvMute;
    @BindView(R2.id.iv_hands_free)
    ImageView mIvHandsFree;
    @BindView(R2.id.tv_avatar)
    TextView  mTvAvatar;
    @BindView(R2.id.tv_desc)
    TextView  mTvDesc;
    @BindView(R2.id.tv_hint)
    TextView  mTvHint;
    @BindView(R2.id.tv_time)
    TextView  mTvTime;
    @BindView(R2.id.tv_mute)
    TextView  mTvMute;
    @BindView(R2.id.tv_hands_free)
    TextView  mTvHandsFree;

    public WechatVoiceCallDetailActivity() {
        super(R.layout.activity_wechat_voice_call_detail);
        isChangeStatusBarTxtColor = false;
    }

    public static void start(Context act, boolean isToAnswer, String time, WechatContactBean wechatContactBean) {
        Intent it = new Intent(act, WechatVoiceCallDetailActivity.class);
        it.putExtra("wechatContactBean", wechatContactBean);
        it.putExtra("isToAnswer", isToAnswer);
        it.putExtra("time", time);
        act.startActivity(it);
    }

    @Override
    protected void initView() {
        setStatusBarColor(Color.parseColor("#000000"));
        setNavigationColor(Color.parseColor("#f7f7f7"));
        //deliver_data
        WechatContactBean wechatContactBean = (WechatContactBean) getIntent().getSerializableExtra("wechatContactBean");
        boolean isToAnswer = getIntent().getBooleanExtra("isToAnswer", false);
        String time = getIntent().getStringExtra("time");
        //show
        if (wechatContactBean != null) {
            if (wechatContactBean.getAvatarSrc() == Constant.SourceType.AVATAR_SRC_SDCARD) {
                Picasso.get().load("file://" + wechatContactBean.getAvatar()).error(R.drawable.ic_wx_default_avatar)
                        .into
                                (mIvAvatar);
            } else {
                String imgUrl = "file:///android_asset/avatars/" + wechatContactBean.getAvatar();
                Picasso.get().load(imgUrl).error(R.drawable.ic_wx_default_avatar)
                        .into
                                (mIvAvatar);
            }
            mTvAvatar.setText(TextUtils.isEmpty(wechatContactBean.getName()) ? "" : wechatContactBean.getName());
        }
        //switch_show
        mTvDesc.setVisibility(isToAnswer ? View.VISIBLE : View.GONE);
        mTvDesc.setText("正在等待对方接受邀请");
        mTvHint.setText(isToAnswer ? "请用听筒接听" : "已接通");
        mTvTime.setVisibility(isToAnswer ? View.GONE : View.VISIBLE);
        mTvTime.setText(time);
        mIvMute.setImageResource(isToAnswer ? R.drawable.wechat_mute_gray : R.drawable.wechat_mute);
        mTvMute.setTextColor(getResources().getColor(isToAnswer ? R.color.gray1 : R.color.white));
        //        mIvHandsFree.setImageResource(isToAnswer ? R.drawable.wechat_hands_free_gray : R.drawable.wechat_hands_free);
        //        mTvHandsFree.setTextColor(getResources().getColor(isToAnswer ? R.color.gray1 : R.color.white));
    }
}
